package cn.edu.scau.cmi.wuzhenxin.client;

import javafx.fxml.FXML;

import javafx.scene.control.Button;
import cn.edu.scau.cmi.wuzhenxin.abstractFactory.factory.AbstractFactory;
import cn.edu.scau.cmi.wuzhenxin.domain.Insure;
import javafx.event.ActionEvent;

import javafx.scene.control.TextArea;

import javafx.scene.layout.AnchorPane;

import javafx.scene.control.CheckBox;

import javafx.scene.control.ChoiceBox;

public class MyController3 {
	@FXML
	private AnchorPane InsureCom;
	@FXML
	private Button showbt;
	@FXML
	private ChoiceBox<String> name;
	@FXML
	private TextArea detilText;
	@FXML
	private CheckBox PICC;
	@FXML
	private CheckBox PingAn;

	@FXML
	public void eventButton(ActionEvent event) {
		String brand = "PICC";
		if(PingAn.isSelected()) {
			brand = "PingAn";
		}else if(PICC.isSelected()) {
			brand = "PICC";
		}
		AbstractFactory factory = AbstractFactory.getFactory(brand);
		Insure insure = null;
		switch(name.getValue().toString()) {
		case "驾驶员身体受伤": insure=factory.createDriverInsure();break;
		case "汽车损坏": insure=factory.createCarInsure();break;
		case "人员伤亡": insure=factory.createPeopleInsure();break;
		case "多种事故": insure=factory.createMulInsure();break;
		default:System.out.println("sorry, your input is not correct");
		}
		detilText.setText(insure.showMessage());
	}
	
	public void choicePICC(ActionEvent event) {
		if(PICC.isSelected()) {
			PingAn.setSelected(false);
		}else {
			PingAn.setSelected(true);
		}
	}
	
	public void choicePingAn(ActionEvent event) {
		if(PingAn.isSelected()) {
			PICC.setSelected(false);
		}else {
			PICC.setSelected(true);
		}
	}
}